<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            height: 300px;
            background: red;
            position: fixed;
            left: 0;
            bottom: 0;
        }

        .box span {
            display: block;
            float: right;
        }
    </style>
</head>

<body>
    <!-- ​3 实现流氓广告的关闭

    显示一个流氓广告框，点击关闭后 4秒钟后继续显示出来 -->
    <div class="box">
        <span class="close">X</span>
    </div>
    <script>
        var boxEle = document.querySelector(".box");
        var closeEle = document.querySelector(".close");
        var flag = true;
        closeEle.onclick = function () {
            boxEle.style.display = "none";
            flag = false;
            if (!flag) {
                setTimeout(function () {
                    boxEle.style.display = "block";
                }, 4000)
            }
        }
    </script>
</body>

</html>